package org.chen;

import io.rebloom.client.Client;
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;

import redis.clients.jedis.JedisPool;

public class BloomFilterTest {
  public static void main(String[] args) {
    GenericObjectPoolConfig config=new GenericObjectPoolConfig();
    config.setMaxIdle(300);
    config.setMaxTotal(1000);
    config.setMaxWaitMillis(30000);
    config.setTestOnBorrow(true);
    JedisPool pool = new JedisPool(config, "192.168.0.187", 6379);
    Client client = new Client(pool);

    //存入10w条数据
    for (int i = 0; i < 100000; i++) {
      client.add("k1","hello "+i);
    }

    //判断数据是否存在，有的数据会存在误判
    boolean e1 = client.exists("k1", "hello 999999");//false
    System.out.println(e1);
    boolean e2 = client.exists("k1", "hello 99999");//false ,可以看出确实存在误判
    System.out.println(e2);
    boolean e3 = client.exists("k1", "hello 9999");//false
    System.out.println(e3);
    boolean e4 = client.exists("k1", "hello 999");//true
    System.out.println(e4);
    boolean e5 = client.exists("k1", "hello 99");//true
    System.out.println(e5);
    boolean e6 = client.exists("k1", "hello 9");//true
    System.out.println(e6);
  }
}
